import {QuestionParagraphDefaultProps, QuestionParagraphPropsType} from "./interface";
import {Typography} from "antd";

const {Paragraph} = Typography
export const Component = (props: QuestionParagraphPropsType) => {
    const {text = '', isCenter = false} = {...QuestionParagraphDefaultProps, ...props}
    // const t = text?.replaceAll('\n', '<br>') || ''
    const textList = text.split('\n')
    return (
        <Paragraph style={{textAlign: isCenter ? 'center' : 'left', marginBottom: 0}}>
            {/*<span dangerouslySetInnerHTML={{__html: t}}></span>*/}
            {
                textList.map((t, index) => (
                    <span key={index}>
                        {index > 0 && <br/>}
                        {t}
                    </span>
                ))
            }
        </Paragraph>
    );
};